package com.example.demo.enums;

import lombok.Getter;

import java.util.HashMap;

@Getter
public enum BookStatus {
    DELETEd(0,"无效"),
    NORMAL(1,"可借阅"),
    FROMAL(2,"不可借阅");

    private int code;
    private String desc;
//
//    public int getCode() {
//        return code;
//    }
//
//    public String getDesc() {
//        return desc;
//    }

    BookStatus(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static BookStatus getBookStatus(int code){
//        HashMap<Integer,BookStatus> map=new HashMap<>();
//        map.put(1,NORMAL);
//        map.put(2,FROMAL);
//        map.put(0,DELETEd);
//        return map.get(code);
        switch (code){
           case 0: return DELETEd;
           case 1: return NORMAL;
           case 2: return FROMAL;
            default: return null;
        }
    }
}
